package com.huamao.niceman.scrollviewpager.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by LuanXianSheng on 2017/6/13.
 */

public abstract class  BaseFragment<V,T extends BasePresent<V>> extends Fragment {
    protected  T mPresent ;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mPresent = creatPresent() ;
        mPresent.attachView((V)this);
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mPresent!= null){
            mPresent.detachView();
        }

    }
    public abstract T creatPresent();
}
